import java.util.Scanner;

public class borrowbook implements doOperation{
    @Override
    public void work(booklist bl) {
        System.out.println("请输入你要借的书名");
        String name;
        Scanner p=new Scanner(System.in);
        name=p.nextLine();

        for(int i=0;i<bl.getUsedsize();i++)
        {
            book a=bl.getbook(i);
            if(a.getName().equals(name)){
                if(a.isIsborrowed()){
                    System.out.println("这本书已经被借出了");
                    return;
                }
                else{
                    a.setIsborrowed(true);
                    System.out.println("借书成功");
                    return;
                }
            }
        }
        System.out.println("没有找到这本书");
        return;

    }
}
